package com.study.lambda.basedemo;

import java.util.Arrays;
import java.util.List;
import java.util.Optional;

public class ParallelStreamDemo {
    public static void main(String[] args) {
        // List<Integer> numbers = Arrays.asList(1, 2, 5, 4);
        // numbers.parallelStream().forEach(num -> System.out.println(Thread.currentThread().getName() + ">>" + num));

        Zoo zoo = new Zoo();
        Optional.ofNullable(zoo).map(Zoo::getDog).map(Dog::getAge).ifPresent(System.out::println
        );
    }
}

class Zoo {
    private Dog dog;

    public Dog getDog() {
        return dog;
    }

    public void setDog(Dog dog) {
        this.dog = dog;
    }
}

class Dog {
    private int age;

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
}